struct MinStack {
  stack: Vec<i32>,
  min_stack: Vec<i32>
}


impl MinStack {
  fn new() -> Self {
    MinStack {
      stack: Vec::new(),
      min_stack: Vec::new()
    }
  }
  
  fn push(&mut self, val: i32) {
    self.stack.push(val);
    if self.min_stack.is_empty() ||  val <= *self.min_stack.last().unwrap() {
      self.min_stack.push(val);
    }
  }
  
  fn pop(&mut self) {
    if self.stack.is_empty() { return; }
    if self.stack.pop().unwrap() == *self.min_stack.last().unwrap() {
      self.min_stack.pop();
    }
  }
  
  fn top(&self) -> i32 {
    return *self.stack.last().unwrap();
  }
  
  fn get_min(&self) -> i32 {
    return *self.min_stack.last().unwrap();
  }
}


fn main() {
  let mut test1: MinStack = MinStack::new();
  test1.push(-2);
  test1.push(0);
  test1.push(-3);
  println!("{}", test1.get_min());
  test1.pop();
  println!("{}", test1.top());
  println!("{}", test1.get_min());
}
